using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BUSLayer;
public partial class FormXemLichChieu : System.Web.UI.Page
{
    PhimBus Phimbus= new PhimBus();
    LichChieuBus LCbus = new LichChieuBus();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            DataTable dt = Phimbus.LayDSPhim();
            GridViewDSPhim.DataSource = dt;
            GridViewDSPhim.DataBind();
        }
    }
    protected void CheckBoxCheckAll_CheckedChanged(object sender, EventArgs e)
    {
        
        for (int i = 0; i < GridViewDSPhim.Rows.Count; i++)
        {
            CheckBox c = (CheckBox)GridViewDSPhim.Rows[i].FindControl("CheckBox1");
            c.Checked = CheckBoxCheckAll.Checked;
        }
       
    }


    protected void ButtonXemLich_Click(object sender, EventArgs e)
    {
        
    }

    private DataTable XuatLichChieu()
    {
        DataTable tbLichChieu = new DataTable();
        tbLichChieu.Columns.Add("TenPhim", typeof(string));
        tbLichChieu.Columns.Add("TenRap", typeof(string));
        tbLichChieu.Columns.Add("NgayChieu", typeof(string));
        tbLichChieu.Columns.Add("ThoiGianBD", typeof(string));
        for (int i = 0; i < GridViewDSPhim.Rows.Count; i++)
        {
            CheckBox c = (CheckBox)GridViewDSPhim.Rows[i].FindControl("CheckBox1");
            if (c.Checked == true)
            {
                int MaPhim = int.Parse(GridViewDSPhim.Rows[i].Cells[2].Text);
                DataTable tbPhim = LCbus.LayLichChieu(MaPhim);
                
                for(int j=0;j< tbPhim.Rows.Count;j++)
                {
                    DataRow Row = tbLichChieu.NewRow();
                    Row[0] = tbPhim.Rows[j]["TenPhim"].ToString();
                    Row[1] = tbPhim.Rows[j]["TenRap"].ToString();
                    Row[2] = tbPhim.Rows[j]["NgayChieu"].ToString();
                    Row[3] = tbPhim.Rows[j]["ThoiGianBD"].ToString();
                    tbLichChieu.Rows.Add(Row);
                }
                
            }
        }
        return tbLichChieu;
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        DataTable dt = LCbus.LayLichChieu(1);
        //DataListLichChieu.DataSource = dt;
        //DataListLichChieu.DataBind();

        GridView1.DataSource = XuatLichChieu();
        GridView1.DataBind();
        
        //Label3.Text = dt.Rows.Count.ToString();*/
    }
}
